var navUI = `
            <nav class="navbar navbar-default" role="navigation">
            <div class="container-fluid">
                <!-- 导航头部 -->
                <div class="navbar-header">
                    <!-- 移动设备上的导航切换按钮 -->
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse-example">
                <span class="sr-only">切换导航</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                </button>
                    <!-- 品牌名称或logo -->
                    <a class="navbar-brand" href="page?p=index">文档管理系统</a>
                </div>
                <!-- 导航项目 -->
                <div class="collapse navbar-collapse navbar-collapse-example">
                    <!-- 一般导航项目 -->
                    <ul class="nav navbar-nav navbar-right">
                        <li class="beforelogin"><a href="page?p=Login">登录</a></li>
                        <li class="beforelogin"><a href="page?p=Register" >注册</a></li>
                        <span hidden="hidden" id='UserNameAcc'></span>
                        <li class="afterlogin"><a id="welcomeName" href="page?p=personCenter">欢迎:cc</a></li>
                        <li class="afterlogin"><a href="page?p=uploadFile">文档上传</a></li>
                        <li class="afterlogin"><a href="page?p=myDocment">我的文档</a></li>
                        <li class="afterlogin"><a href="page?p=runWater">积分流水</a></li>
                        <li class="afterlogin"><a href="javascript:void(0);" id="logoutBtn">注销</a></li>
                    </ul>
                </div>
                <!-- END .navbar-collapse -->
            </div>
            </nav>
        `;
//添加页面元素
$('#head').html(navUI);
//显示名字
var niname = sessionStorage.getItem("niname");
if (niname) {
    $("[class=beforelogin]").each(function() {
        $(this).css("display", "none");
    });
    //编写名字
    $('#UserNameAcc').html(niname);
    $('#welcomeName').html("欢迎你:" + niname);

} else {
    $("[class=afterlogin]").each(function() {
        $(this).css("display", "none");
    });
}
//注销按钮事件
$('#logoutBtn').click(function() {
    //移除登录人员
    sessionStorage.removeItem("niname");
    //跳转
    window.location.href = 'page?p=Login';
});